﻿namespace Digitalmes.Application.Sys.Users.Queries;

/// <summary>
/// 获取用户信息查询命令。
/// </summary>
public record GetUserListQuery : IRequest<IResult<List<SysUserDto>>>;

internal sealed class GetUserListQueryHandler(IRepository<SysUser> repo) : IRequestHandler<GetUserListQuery, IResult<List<SysUserDto>>>
{
    public async Task<IResult<List<SysUserDto>>> Handle(GetUserListQuery request, CancellationToken cancellationToken)
    {
        var items = await repo.AsQueryable()
            .Includes(s => s.Org)
            .ToListAsync(cancellationToken);
        return Result.From(items.Adapt<List<SysUserDto>>());
    }
}
